﻿/*
 * @Autor: PK
 * @Date: 2022/04/18 11:49:SS
 */

using System;
using System.Management;

namespace ShkSimulation.desktop.util {

	public class SystemUtil {
	
		public static string GetCpuName() {
			try {
				ManagementClass managementClass = new ManagementClass("Win32_Processor");
				ManagementObjectCollection managementObjectCollection = managementClass.GetInstances();
				String cpuId = null;
				foreach (var managementBaseObject in managementObjectCollection) {
					var managementObject = (ManagementObject) managementBaseObject;
					cpuId = managementObject["Name"].ToString();
					cpuId = cpuId?.Split('@')[0];
					break;
				}
				return cpuId;
			} catch {
				return "";
			}
		}

	}

}